package com.crpc.core.channelHandler;

import com.crpc.core.proxy.handler.CrpcRequestDecoder;
import com.crpc.core.proxy.handler.CrpcResponseEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author CLOUD
 * @version 1.0
 * @description:
 * @date 2023/9/10 14:19
 */
public class ProviderChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //核心,添加入栈出站handler
        socketChannel.pipeline()
                .addLast(new LoggingHandler(LogLevel.INFO))
                //请求解码器
                .addLast(new CrpcRequestDecoder())
                //响应编码器
                .addLast(new CrpcResponseEncoder())
                //更具请求进行方法调用
                .addLast(new MethodRequestHandler())
        ;
    }
}
